<template>
	<div class="app-container calendar-list-container">
		<div class="filter-container">
			<el-input @keyup.enter.native="handleFilter" style="width: 200px;" class="filter-item" placeholder="社保机构号" v-model.trim="siCardDiff.insCode"> </el-input>
			<el-input @keyup.enter.native="handleFilter" style="width: 200px;" class="filter-item" placeholder="数据差异" v-model.trim="siCardDiff.errorType"> </el-input>
			<!--<el-input @keyup.enter.native="handleFilter" style="width: 200px;" class="filter-item" placeholder="处理状态" v-model.trim="siCardDiff.dealStatus"> </el-input>-->
			<el-select style="width: 200px;" class="filter-item" v-model="selOpton" placeholder="请选择">
				<el-option v-for="item in optionsSearch" :key="item.value" :label="item.label" :value="item.value">
				</el-option>
			</el-select>
			<el-date-picker style="width: 200px;" class="filter-item" v-model="getDt" formatter="yyyy-MM-dd" @change="getSTime" type="date" placeholder="日期"></el-date-picker>
			<el-button class="filter-item" type="primary" v-waves icon="search" @click="handleFilter">搜索</el-button>
			<el-button v-if="siCardDiffManager_btn_synchronization" class="filter-item" type="primary" :loading="false" @click="ChooseData" v-waves style="float: right;">确定同步</el-button>
			<!--			<a :href="derivedExcleForHref">-->
			<el-button v-if="siCardDiffManager_btn_download" class="filter-item" style="margin-left: 10px;" type="primary" @click="derivedExcleForVue">点击下载Excel
			</el-button>
			<!--</a>-->
			<!--<el-button class="filter-item" v-if="siCardDiffManager_btn_add" style="margin-left: 10px;" @click="handleCreate" type="primary" icon="edit">添加</el-button>-->
		</div>

		<el-table ref="elementTable" :key='tableKey' :data="list" v-loading.body="listLoading" border fit highlight-current-row style="width: 100%" @selection-change="handleSelectionChange">
			<el-table-column type="selection" width="55"> </el-table-column>
			<el-table-column type="index" label="序号" header-align="center" align="center" width="65">
				<template scope="scope"><span>{{scope.$index+(siCardDiff.page - 1) * siCardDiff.limit + 1}} </span></template>
			</el-table-column>
			<el-table-column width="200px" align="center" label="社保机构号">
				<template scope="scope">
					<span>{{scope.row.insCode}}</span>
				</template>
			</el-table-column>
			<el-table-column width="200px" align="center" label="城市代码">
				<template scope="scope">
					<span>{{scope.row.cityCode}}</span>
				</template>
			</el-table-column>
			<el-table-column width="200px" align="center" label="行政区划码">
				<template scope="scope">
					<span>{{scope.row.cityNo}}</span>
				</template>
			</el-table-column>
			<el-table-column width="200px" align="center" label="支付宝用户ID">
				<template scope="scope">
					<span>{{scope.row.userId}}</span>
				</template>
			</el-table-column>
			<el-table-column width="200px" align="center" label="平台绑卡状态">
				<template scope="scope">
					<span>{{scope.row.signStatus}}</span>
				</template>
			</el-table-column>
			<el-table-column width="200px" align="center" label="域内行政区划码">
				<template scope="scope">
					<span>{{scope.row.innerCityCode}}</span>
				</template>
			</el-table-column>
			<el-table-column width="200px" align="center" label="域内绑卡状态">
				<template scope="scope">
					<span>{{scope.row.status}}</span>
				</template>
			</el-table-column>
			<el-table-column width="200px" align="center" label="数据差异">
				<template scope="scope">
					<span>{{scope.row.errorType}}</span>
				</template>
			</el-table-column>
			<el-table-column width="200px" align="center" label="处理状态">
				<template scope="scope">
					<span>{{scope.row.dealStatus}}</span>
				</template>
			</el-table-column>
			<el-table-column width="200px" align="center" label="最后更新时间">
				<template scope="scope">
					<span>{{scope.row.gmtModifiedCloud}}</span>
				</template>
			</el-table-column>
			<!--
			<el-table-column width="200px" align="center" label="状态最后更新时间">
				<template scope="scope">
					<span>{{scope.row.gmtTime}}</span>
				</template>
			</el-table-column>
			<el-table-column align="center" label="社保机构号" width="200px" >
				<template scope="scope">
					<span>{{scope.row.insCode}}</span>
				</template>
			</el-table-column>
			<el-table-column width="200px" align="center" label="云分表主键">
				<template scope="scope">
					<span>{{scope.row.yyId}}</span>
				</template>
			</el-table-column>
			<el-table-column width="200px" align="center" label="卡内码">
				<template scope="scope">
					<span>{{scope.row.medicalCardId}}</span>
				</template>
			</el-table-column>
			<el-table-column width="200px" align="center" label="ods的id可能重复">
				<template scope="scope">
					<span>{{scope.row.odsId}}</span>
				</template>
			</el-table-column>
			<el-table-column width="200px" align="center" label="持卡人和userId的关系00:本人01:父子02:母子03:其他">
				<template scope="scope">
					<span>{{scope.row.relationType}}</span>
				</template>
			</el-table-column>
			<el-table-column width="200px" align="center" label="医疗证号（或者外部主键）">
				<template scope="scope">
					<span>{{scope.row.insCardId}}</span>
				</template>
			</el-table-column>
			<el-table-column width="200px" align="center" label="激活时间">
				<template scope="scope">
					<span>{{scope.row.gmtActivedTime}}</span>
				</template>
			</el-table-column>
			<el-table-column width="200px" align="center" label="解绑时间">
				<template scope="scope">
					<span>{{scope.row.gmtUnbindTime}}</span>
				</template>
			</el-table-column>
			<el-table-column width="200px" align="center" label="修改时间">
				<template scope="scope">
					<span>{{scope.row.gmtModified}}</span>
				</template>
			</el-table-column>
			
			<el-table-column width="200px" align="center" label="日期">
				<template scope="scope">
					<span>{{scope.row.dt}}</span>
				</template>
			</el-table-column>-->

			<el-table-column fixed="right" align="center" label="操作" width="150">
				<template scope="scope">
					<el-button v-if="siCardDiffManager_view" size="small" type="success" @click="checkedFn(scope.row)">查看
					</el-button>
					<!--<el-button v-if="siCardDiffManager_btn_edit" size="small" type="success" @click="handleUpdate(scope.row)">编辑
					</el-button>
					<el-button v-if="siCardDiffManager_btn_del" size="small" type="danger" @click="handleDelete(scope.row)">删除
					</el-button>-->
				</template>
			</el-table-column>
		</el-table>
		<div v-show="!listLoading" class="pagination-container">
			<!--<el-button :span="8" class="filter-item" type="primary"  @click="handleFilter">确定</el-button>-->
			<el-pagination :span="16" @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="siCardDiff.page" :page-sizes="[10,20,30, 50,100,200,500,1000,2000]" :page-size="siCardDiff.limit" layout="total, sizes, prev, pager, next, jumper" :total="total"> </el-pagination>

		</div>
		<el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible">
			<el-form :model="form" :rules="rules" ref="form" label-width="100px">

				<el-form-item label="社保机构号" prop="insCode">
					<el-input v-model="form.insCode" placeholder="社保机构号"></el-input>
				</el-form-item>
				<el-form-item label="支付宝用户ID" prop="userId">
					<el-input v-model="form.userId" placeholder="请输入支付宝用户ID"></el-input>
				</el-form-item>
				<el-form-item label="云分表主键" prop="yyId">
					<el-input v-model="form.yyId" placeholder="请输入云分表主键"></el-input>
				</el-form-item>
				<el-form-item label="平台绑卡状态,成功绑定:ACTIVED;成功解绑：DELETE；绑定中：BINDING；解绑中：DELETING" prop="signStatus">
					<el-input v-model="form.signStatus" placeholder="请输入平台绑卡状态,成功绑定:ACTIVED;成功解绑：DELETE；绑定中：BINDING；解绑中：DELETING"></el-input>
				</el-form-item>
				<el-form-item label="城市代码" prop="cityCode">
					<el-input v-model="form.cityCode" placeholder="请输入城市代码"></el-input>
				</el-form-item>
				<el-form-item label="行政区划码" prop="cityNo">
					<el-input v-model="form.cityNo" placeholder="请输入行政区划码"></el-input>
				</el-form-item>
				<el-form-item label="状态最后更新时间" prop="gmtTime">
					<el-input v-model="form.gmtTime" placeholder="请输入状态最后更新时间"></el-input>
				</el-form-item>
				<el-form-item label="最后更新时间" prop="gmtModifiedCloud">
					<el-input v-model="form.gmtModifiedCloud" placeholder="请输入最后更新时间"></el-input>
				</el-form-item>
				<el-form-item label="卡内码" prop="medicalCardId">
					<el-input v-model="form.medicalCardId" placeholder="请输入卡内码"></el-input>
				</el-form-item>
				<el-form-item label="ods的id可能重复" prop="odsId">
					<el-input v-model="form.odsId" placeholder="请输入ods的id可能重复"></el-input>
				</el-form-item>
				<el-form-item label="域内绑卡状态" prop="status">
					<el-input v-model="form.status" placeholder="请输入域内绑卡状态"></el-input>
				</el-form-item>
				<el-form-item label="域内行政区划码" prop="innerCityCode">
					<el-input v-model="form.innerCityCode" placeholder="请输入域内行政区划码"></el-input>
				</el-form-item>
				<el-form-item label="持卡人和userId的关系" prop="relationType">
					<el-input v-model="form.relationType " placeholder="请输入持卡人和userId的关系00:本人01:父子02:母子03:其他 "></el-input>
				</el-form-item>
				<el-form-item label="医疗证号（或者外部主键） " prop="insCardId ">
					<el-input v-model="form.insCardId " placeholder="请输入医疗证号（或者外部主键） "></el-input>
				</el-form-item>
				<el-form-item label="激活时间 " prop="gmtActivedTime ">
					<el-input v-model="form.gmtActivedTime " placeholder="请输入激活时间 "></el-input>
				</el-form-item>
				<el-form-item label="解绑时间 " prop="gmtUnbindTime ">
					<el-input v-model="form.gmtUnbindTime " placeholder="请输入解绑时间 "></el-input>
				</el-form-item>
				<el-form-item label="修改时间 " prop="gmtModified ">
					<el-input v-model="form.gmtModified " placeholder="请输入修改时间 "></el-input>
				</el-form-item>
				<el-form-item label="数据差异&错误类型 DIFF01~xx " prop="errorType ">
					<el-input v-model="form.errorType " placeholder="请输入数据差异&错误类型 DIFF01~xx "></el-input>
				</el-form-item>
				<el-form-item label="日期 " prop="dt ">
					<el-input v-model="form.dt " placeholder="请输入日期 "></el-input>
				</el-form-item>
				<el-form-item label="处理状态：初始化 INIT, 已经处理 DEAL , 处理失败 ERROR " prop="dealStatus ">
					<el-input v-model="form.dealStatus " placeholder="请输入处理状态：初始化 INIT, 已经处理 DEAL , 处理失败 ERROR "></el-input>
				</el-form-item>
			</el-form>
			<div slot="footer " class="dialog-footer ">
				<el-button @click="cancel( 'form') ">取 消</el-button>
				<el-button v-if="dialogStatus=='create' " type="primary " @click="create( 'form') ">确 定</el-button>
				<el-button v-if="dialogStatus=='update' " type="primary " @click="update( 'form') ">确 定</el-button>
			</div>
		</el-dialog>
		<el-dialog :title="textMap[dialogStatus] " :visible.sync="dialogFormVisibleView ">
			<el-form :model="form " :rules="rules " ref="form " label-width="100px ">
				<el-form-item label="社保机构号 " prop="insCode ">
					<el-input v-model="form.insCode " placeholder="社保机构号 " readonly></el-input>
				</el-form-item>
				<el-form-item label="支付宝用户ID " prop="userId ">
					<el-input v-model="form.userId " placeholder="请输入支付宝用户ID " readonly></el-input>
				</el-form-item>
				<el-form-item label="云分表主键 " prop="yyId ">
					<el-input v-model="form.yyId " placeholder="请输入云分表主键 " readonly></el-input>
				</el-form-item>
				<el-form-item label="平台绑卡状态 " prop="signStatus ">
					<el-input v-model="form.signStatus " placeholder="请输入平台绑卡状态,成功绑定:ACTIVED;成功解绑：DELETE；绑定中：BINDING；解绑中：DELETING " readonly></el-input>
				</el-form-item>
				<el-form-item label="城市代码 " prop="cityCode ">
					<el-input v-model="form.cityCode " placeholder="请输入城市代码 " readonly></el-input>
				</el-form-item>
				<el-form-item label="行政区划码 " prop="cityNo ">
					<el-input v-model="form.cityNo " placeholder="请输入行政区划码 " readonly></el-input>
				</el-form-item>
				<el-form-item label="状态最后更新时间 " prop="gmtTime ">
					<el-input v-model="form.gmtTime " placeholder="请输入状态最后更新时间 " readonly></el-input>
				</el-form-item>
				<el-form-item label="最后更新时间 " prop="gmtModifiedCloud ">
					<el-input v-model="form.gmtModifiedCloud " placeholder="请输入最后更新时间 " readonly></el-input>
				</el-form-item>
				<el-form-item label="卡内码 " prop="medicalCardId ">
					<el-input v-model="form.medicalCardId " placeholder="请输入卡内码 " readonly></el-input>
				</el-form-item>
				<el-form-item label="ods的id可能重复 " prop="odsId ">
					<el-input v-model="form.odsId " placeholder="请输入ods的id可能重复 " readonly></el-input>
				</el-form-item>
				<el-form-item label="域内绑卡状态 " prop="status ">
					<el-input v-model="form.status " placeholder="请输入域内绑卡状态 " readonly></el-input>
				</el-form-item>
				<el-form-item label="域内行政区划码 " prop="innerCityCode ">
					<el-input v-model="form.innerCityCode " placeholder="请输入域内行政区划码 " readonly></el-input>
				</el-form-item>
				<el-form-item label="持卡人和userId的关系 " prop="relationType ">
					<el-input v-model="form.relationType " placeholder="请输入持卡人和userId的关系00:本人01:父子02:母子03:其他 " readonly></el-input>
				</el-form-item>
				<el-form-item label="医疗证号 " prop="insCardId ">
					<el-input v-model="form.insCardId " placeholder="请输入医疗证号（或者外部主键） " readonly></el-input>
				</el-form-item>
				<el-form-item label="激活时间 " prop="gmtActivedTime ">
					<el-input v-model="form.gmtActivedTime " placeholder="请输入激活时间 " readonly></el-input>
				</el-form-item>
				<el-form-item label="解绑时间 " prop="gmtUnbindTime ">
					<el-input v-model="form.gmtUnbindTime " placeholder="请输入解绑时间 " readonly></el-input>
				</el-form-item>
				<el-form-item label="修改时间 " prop="gmtModified ">
					<el-input v-model="form.gmtModified " placeholder="请输入修改时间 " readonly></el-input>
				</el-form-item>
				<el-form-item label="数据差异 " prop="errorType ">
					<el-input v-model="form.errorType " placeholder="请输入数据差异&错误类型 DIFF01~xx " readonly></el-input>
				</el-form-item>
				<el-form-item label="日期 " prop="dt ">
					<el-input v-model="form.dt " placeholder="请输入日期 " readonly></el-input>
				</el-form-item>
				<el-form-item label="处理状态 " prop="dealStatus ">
					<el-input v-model="form.dealStatus " placeholder="请输入处理状态：初始化 INIT, 已经处理 DEAL , 处理失败 ERROR " readonly></el-input>
				</el-form-item>
			</el-form>
			<div slot="footer " class="dialog-footer ">
				<el-button @click="cancel( 'form') ">取 消</el-button>
				<el-button type="primary " @click="cancel( 'form') ">确 定</el-button>
			</div>
		</el-dialog>
		<el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisibleTwo">
			<div class="filter-container">
				<el-progress :text-inside="true" :stroke-width="18" :percentage="progressPercentage" status="success" color="rgba(142, 113, 199, 0.7)"></el-progress>
			</div>
			<el-form :model="form" :rules="rules" ref="form" label-width="100px">

				<el-form-item label="返回成功" prop="synchronizationResultValSuccess">
					<el-input type="textarea" :autosize="{ minRows: 5, maxRows: 10}" v-model="form.synchronizationResultValSuccess" placeholder="返回json字符串"></el-input>
				</el-form-item>
				<el-form-item label="返回失败" prop="synchronizationResultValWarning">
					<el-input type="textarea" :autosize="{ minRows: 5, maxRows: 10}" v-model="form.synchronizationResultValWarning" placeholder="返回json字符串"></el-input>
				</el-form-item>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button @click="cancel('form')">取 消</el-button>
				<el-button type="primary" @click="cancel('form')">确 定</el-button>
			</div>
		</el-dialog>
	</div>
</template>

<script>
	import {
		page,
		addObj,
		cardSynchronization,
		derivedExcleFor,
		getObj,
		delObj,
		putObj
	} from 'api/admin/siCardDiff/index';
	import { mapGetters } from 'vuex';
	import { getToken } from 'utils/auth';
	export default {
		name: 'siCardDiff',
		data() {
			return {
				getDt: '',
				derivedExcleForHref: '',
				optionsSearch: [{
					value: 'INIT',
					label: '初始化 '
				}, {
					value: 'DEAL',
					label: '已经处理'
				}, {
					value: 'NODEAL',
					label: '数据一致，不需要处理'
				}, {
					value: 'ERROR',
					label: '处理失败'
				}],
				selOpton: 'INIT',
				form: {
					insCode: undefined,
					userId: undefined,
					yyId: undefined,
					signStatus: undefined,
					cityCode: undefined,
					cityNo: undefined,
					gmtTime: undefined,
					gmtModifiedCloud: undefined,
					medicalCardId: undefined,
					odsId: undefined,
					status: undefined,
					innerCityCode: undefined,
					relationType: undefined,
					insCardId: undefined,
					gmtActivedTime: undefined,
					gmtUnbindTime: undefined,
					gmtModified: undefined,
					errorType: undefined,
					dt: undefined,
					dealStatus: undefined,
					message: undefined,
					synchronizationResultValSuccess: '',
					synchronizationResultValWarning: ''
				},
				rules: {},
				list: null,
				total: null,
				listLoading: true,
				isCheckAll: false,
				siCardDiff: {
					page: 1,
					limit: 10
				},
				dialogFormVisible: false,
				dialogFormVisibleTwo: false,
				flag: false,
				progressPercentage: 0,
				selectChangeVal: undefined,
				dialogFormVisibleView: false,
				dialogStatus: '',
				siCardDiffManager_btn_edit: false,
				siCardDiffManager_btn_del: false,
				siCardDiffManager_btn_add: false,
				siCardDiffManager_view: false,
				textMap: {
					update: '编辑',
					checked: '查看',
					create: '创建',
					download: '下载'
				},
				tableKey: 0
			}
		},
		created() {
			this.getList();
			this.siCardDiffManager_btn_edit = this.elements['siCardDiffManager:btn_edit'];
			this.siCardDiffManager_btn_del = this.elements['siCardDiffManager:btn_del'];
			this.siCardDiffManager_btn_add = this.elements['siCardDiffManager:btn_add'];
			this.siCardDiffManager_view = this.elements['siCardDiffManager:view'];
			this.siCardDiffManager_btn_download = this.elements['siCardDiffManager:btn_download'];
			this.siCardDiffManager_btn_synchronization = this.elements['siCardDiffManager:btn_synchronization'];
		},
		computed: {
			...mapGetters([
				'elements'
			])
		},
		methods: {
			//点击查看按钮
			checkedFn(data) {
				this.dialogStatus = 'checked';
				this.dialogFormVisibleView = true;
				this.form = data
				// this.jgAddOpton = this.form.organType
				// this.ztAddOpton = this.form.state
			},
			getList() {
				if(!this.isCheckAll) {
					this.listLoading = false;
				} else {
					this.listLoading = true;
					page(this.siCardDiff)
						.then(response => {
							this.list = response.data.rows;
							this.total = response.data.total;
							this.listLoading = false;
						})
				}
			},
			// 日期插件增加的方法 修改日期格式
			getSTime(val) {
				this.getDt = val
				this.siCardDiff.dt = val;
			},
			handleFilter() {
				/*if(!this.siCardDiff.errorType && !this.siCardDiff.dt) {
					this.$message({
						message: '搜索条件不能都为空',
						duration: '2000',
						type: 'warning'
					})
					return false
				}*/
				this.siCardDiff.dealStatus = this.selOpton;
				this.isCheckAll = true;
				this.getList();
			},
			derivedExcleForVue() {
				this.siCardDiff.dealStatus = this.selOpton;
				if(!this.siCardDiff.dt) {
					this.$message({
						message: '日期不能为空！',
						type: 'warning',
						duration: '2000'
					});
				} else {
					this.$confirm('此操作将下载所有满足条件的数据, 是否继续?', '提示', {
							confirmButtonText: '确定',
							cancelButtonText: '取消',
							type: 'warning'
						})
						.then(() => {
							let a = document.createElement("a");
							a.href = "/api/siCardDiff/derivedExcleForSiCardDiff?insCode=" + this.siCardDiff.insCode + "&errorType=" + this.siCardDiff.errorType + "&dealStatus=" + this.selOpton + "&dt=" + this.siCardDiff.dt+"&token="+getToken();
							a.click();
						});
				}
			},
			ChooseData() {
				//this.flag=true;
				this.dialogFormVisibleTwo = false;
				if(!this.selectChangeVal || this.selectChangeVal == "") {
					this.$message({
						message: '请选择需要同步的数据！',
						type: 'warning',
						duration: '2000'
					});
					return;
				}
				this.$confirm('此操作将同步域内绑卡状态, 是否继续?', '提示', {
						confirmButtonText: '确定',
						cancelButtonText: '取消',
						type: 'warning'
					})
					.then(() => {
						let count = 1;
						var timer = setInterval(() => {
							if(count >= this.selectChangeVal.length) { 
								clearInterval(timer);
							} 
							this.progressPercentage = 100 * (count) / this.selectChangeVal.length;  
						}, 1.5);
						let selectChangeValSuccess = new Array();
						let selectChangeValWarning = new Array();
						for(let i = 0; i < this.selectChangeVal.length; i++) {
							cardSynchronization(this.selectChangeVal[i])
								.then((result) => {
									count++;
									if(result.status == 0) {
										this.form.synchronizationResultValSuccess = this.form.synchronizationResultValSuccess + result.data + "\n";
										/*selectChangeValSuccess.push(result.data);
										this.form.synchronizationResultValSuccess = selectChangeValSuccess.join("\n");*/
									} else {
										this.form.synchronizationResultValWarning = this.form.synchronizationResultValWarning + result.data + "\n";
										/*selectChangeValWarning.push(result.data);
										this.form.synchronizationResultValWarning = selectChangeValWarning.join("\n");*/
									}

								})
						}
						this.dialogFormVisibleTwo = true;
						count--;
					});
				//				this.progressPercentage = 0;
			},
			handleSelectionChange(val) {
				this.selectChangeVal = val;
				this.dialogFormVisibleTwo = false;
				//				this.progressPercentage = 0;
			},
			handleSizeChange(val) {
				this.siCardDiff.limit = val;
				this.getList();
			},
			handleCurrentChange(val) {
				this.siCardDiff.page = val;
				this.getList();
			},
			handleCreate() {
				this.resetTemp();
				this.dialogStatus = 'create';
				this.dialogFormVisible = true;
			},
			handleUpdate(data) {
				this.dialogStatus = 'update';
				this.dialogFormVisible = true;
				this.form = data
			},
			handleDelete(row) {
				this.$confirm('此操作将永久删除, 是否继续?', '提示', {
						confirmButtonText: '确定',
						cancelButtonText: '取消',
						type: 'warning'
					})
					.then(() => {
						delObj(row.id)
							.then(() => {
								this.$notify({
									title: '成功',
									message: '删除成功',
									type: 'success',
									duration: 2000
								});
								const index = this.list.indexOf(row);
								this.list.splice(index, 1);
							});
					});
			},
			create(formName) {
				const set = this.$refs;
				set[formName].validate(valid => {
					if(valid) {
						addObj(this.form)
							.then((res) => {
								if(res.status === -1) {
									this.$message.error({
										message: '卡内码不能为空！',
										type: 'warning',
										duration: '2000'
									});
								} else {
									this.dialogFormVisible = false;
									this.getList();
									this.$notify({
										title: '成功',
										message: '创建成功',
										type: 'success',
										duration: 2000
									});
								}
							})
					} else {
						return false;
					}
				});
			},
			cancel(formName) {
				this.dialogFormVisible = false;
				this.dialogFormVisibleView = false;
				this.dialogFormVisibleTwo = false;
				this.progressPercentage = 0;
				const set = this.$refs;
				set[formName].resetFields();
			},
			update(formName) {
				const set = this.$refs;
				set[formName].validate(valid => {
					if(valid) {
						this.dialogFormVisible = false;
						this.form.password = undefined;
						putObj(this.form).then((res) => {
							if(res.status === -1) {
								this.$message.error({
									message: '卡内码不能为空！',
									duration: '2000',
								})
							} else {
								this.dialogFormVisible = false;
								this.getList();
								this.$notify({
									title: '成功',
									message: '编辑成功',
									type: 'success',
									duration: 2000
								});
							}
						});
					} else {
						return false;
					}
				});
			},
			resetTemp() {
				this.form = {
					username: undefined,
					name: undefined,
					sex: '男',
					password: undefined,
					description: undefined
				};
			}
		}
	}
</script>